package com.huike.web.controller.report;

import com.huike.clues.domain.TbActivity;
import com.huike.clues.domain.TbClue;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import com.huike.contract.domain.TbContract;
import com.huike.report.domain.vo.ActivityStatisticsVo;
import com.huike.report.domain.vo.LineChartVo;
import com.huike.report.domain.vo.VulnerabilityMapVo;
import com.huike.report.service.IReportService;
import com.huike.web.result.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@Api(tags = "统计分析相关接口")
@RestController
@RequestMapping("/report")
public class ReportController extends BaseController {

    @Resource
   private IReportService reportService;

    @ApiOperation("客户统计新增客户数报表")
    @GetMapping("/contractStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVo contractStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return reportService.contractStatistics(beginCreateTime,endCreateTime);
    }

    @ApiOperation("客户统计学科分布统计报表")
    @GetMapping("/subjectStatistics/{beginCreateTime}/{endCreateTime}")
    public AjaxResult<List<ReportSubjectStatisticsData>> subjectStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return AjaxResult.success(reportService.subjectStatistics(beginCreateTime,endCreateTime));
    }

    //统计列表
    @ApiOperation("客户统计明细列表")
    @GetMapping("/contractStatisticsList")
    public TableDataInfo<List<TbContract>> contractStatisticsList(TbContract contract)
    {
        startPage();
        List<TbContract> list= reportService.contractReportList(contract);
        return getDataTable(list);
    }



    @ApiOperation("销售统计报表")
    @GetMapping("/salesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVo salesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
      return reportService.salesStatistics(beginCreateTime,endCreateTime);
    }

    @ApiOperation("销售统计归属渠道明细列表")
    @GetMapping("/channelStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo<List<ReportSalesChannelStatisticsListData>> channelStatisticsList(@PathVariable String beginCreateTime, @PathVariable String endCreateTime)
    {
        startPage();
        List<Map<String, Object>> list= reportService.channelStatisticsList(beginCreateTime,endCreateTime);
        return getDataTablePage(list);
    }

    @ApiOperation("销售统计归属部门明细列表")
    @GetMapping("/deptStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo<List<ReportSalesDeptStatisticsListData>> deptStatisticsList(@PathVariable String beginCreateTime, @PathVariable String endCreateTime)
    {
        startPage();
        List<Map<String, Object>> list= reportService.deptStatisticsList(beginCreateTime,endCreateTime);
        return getDataTablePage(list);
    }

    @ApiOperation("销售统计归属人报表")
    @GetMapping("/ownerShipStatisticsList/{beginCreateTime}/{endCreateTime}")
    public TableDataInfo<List<ReportSalesOwnerShipStatisticsListData>> ownerShipStatisticsList(@PathVariable String beginCreateTime, @PathVariable String endCreateTime)
    {
        startPage();
        List<Map<String, Object>> list = reportService.ownerShipStatisticsList(beginCreateTime,endCreateTime);
        return getDataTablePage(list);
    }



    @ApiOperation("线索统计新增线索数量报表")
    @GetMapping("/cluesStatistics/{beginCreateTime}/{endCreateTime}")
    public LineChartVo cluesStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return reportService.cluesStatistics(beginCreateTime,endCreateTime);
    }

    @ApiOperation("线索统计线索转换率报表")
    @GetMapping("/getVulnerabilityMap/{beginCreateTime}/{endCreateTime}")
    public AjaxResult<VulnerabilityMapVo> getVulnerabilityMap(@PathVariable String beginCreateTime, @PathVariable String endCreateTime)
    {
        VulnerabilityMapVo vulnerabilityMapDTO= reportService.getVulnerabilityMap(beginCreateTime,endCreateTime);
        return AjaxResult.success(vulnerabilityMapDTO);
    }

    @ApiOperation("线索统计明细列表")
    @GetMapping("/cluesStatisticsList")
    public TableDataInfo<List<TbClue>> cluesStatisticsList(TbClue clue)
    {
        startPage();
        List<TbClue> list= reportService.cluesStatisticsList(clue);
        return getDataTable(list);
    }



    @ApiOperation("渠道统计")
    @GetMapping("/chanelStatistics/{beginCreateTime}/{endCreateTime}")
    public AjaxResult<List<ReportChannelStatisticsData>> chanelStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return AjaxResult.success(reportService.chanelStatistics(beginCreateTime,endCreateTime));
    }


    @ApiOperation("渠道统计-活动统计")
    @GetMapping("/activityStatistics/{beginCreateTime}/{endCreateTime}")
    public AjaxResult<List<ReportActivityStatisticsData>> activityStatistics(@PathVariable String beginCreateTime, @PathVariable String endCreateTime){
        return AjaxResult.success(reportService.activityStatistics(beginCreateTime,endCreateTime));
    }


    @ApiOperation("渠道统计活动明细列表")
    @GetMapping("/activityStatisticsList")
    public TableDataInfo<List<ActivityStatisticsVo>> activityStatisticsList(TbActivity activity) {
        List<ActivityStatisticsVo> list= reportService.activityStatisticsList(activity);
        return getDataTablePage(list);
    }

}
